<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>2222</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<link href="/resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="/resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <!-- <script src="/resources/lib/ligerUI/js/core/base.js" type="text/javascript"></script> -->
    <script src="/resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <script src="/resources/lib/ligerUI/js/plugins/ligerForm.js"></script>
    <script src="/resources/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
   	<script src="/resources/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="/resources/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
    <script src="/resources/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
    <script src="/resources/lib/json2.js" type="text/javascript"></script>
    <script src="/resources/js/md5.js" type="text/javascript"></script>
    <script type="text/javascript">
    var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
    var node = dialog.options.data;
    var parentData = null;
    var target = null;
    if(node){
    	parentData = node.data;
    	target = node.target;
    }
    var action_type =  dialog.options.action_type;
    var number = '${number}';
    var status ='${status}';
    var customerClassification_data = '${customerClassification_data}';
    console.log(dialog);
    var form = null;
    $(function (){
           form = $("form").ligerForm({
                inputWidth: 170, labelWidth: 90, space: 40,
                validate: true,
                fields: [ 
                         { name: "uuid", newline: true, type: "hidden"},
                         { name: "parentId", newline: true, type: "hidden"},
                         { name: "leaf", type: "hidden"},
                         { label: "父节点名", name: "parentName", newline: true, type: "text",options:{readonly:true}},
                         { label: "分类编号", name: "number", newline: true, type: "text",validate: {required: true,minlength: 4 }},
                         { label: "分类名称", name: "name", newline: true, type: "text", validate: {required: true}},
                         { label: "分类级别", name: "level", newline: true, type: "spinner",validate: {required: true},options:{type:"int",readonly:true} }

                     ],
                buttons :[
						{ text: '提交', click: submitForm,attr:''}
                          ]
            }); 
           if(status == '0'){
        	   var fdata = {
        			parentId:parentData.uuid,
        			parentName:parentData.name,
        			number:number,
        			leaf:true,
        			level:typeof(parentData.level)=='undefined'?'00000':parentData.level+1
        	   };
        	   form.setData(fdata);
        	  /*  if(number){
         		  var numberE = form.getEditor("number"); //form中应用
         		  numberE.setValue(number);
         	  } */
           }else if(status == '2'){
        	   if(customerClassification_data){
        		   form.setData(JSON.parse(customerClassification_data));
        	   }
           }
        }); 
        
        function submitForm(){
 			if (form.valid())
             {
 				var data = form.getData(); 
 				//data.old_pwd = b64_md5(data.old_pwd);  
 	             //data.new_pwd = b64_md5(data.new_pwd); 
 	             //data.new_re_pwd = b64_md5(data.new_re_pwd); 
 				$.ajax({
                    loading: '提交中。。。',
                    type:'post',
                    url: "/customerClassification/saveOrUpdateCustomerClassification",
                    data: data,
                    dataType:'json',
                    success: function (json) {
                    	if(json.code=='SUCCESS'){
                    		$.ligerDialog.success(json.message,"系统提示",function(){
                    			parent.$.ligerDialog.close(); //关闭弹出窗; //关闭弹出窗
                    			parent.$(".l-dialog,.l-window-mask").css("display","none"); //只隐藏遮罩层
                    			data.uuid=json.str;
                    			window.parent.appendOrUpdateNode(status,target,data);
                    			// window.parent.reloadTree();//调用父窗口方法
                    		});
                    	}else{
                    		 $.ligerDialog.error(json.message,"系统提示");
                    	}
                    	console.log(json);
                    },
                    error: function (message) {
                        alert(message);
                    }
                });
             }
             else
             {
                 form.showInvalid();
             } 
        }

    </script>
   <!--  <style type="text/css">
        .l-table-edit {}
        .l-table-edit-td{ padding:4px;}
        .l-button-submit,.l-button-reset{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    </style> -->

</head>

<body style="padding:10px">
<form id="form2" ></form> 
<div style="display:none">
     
</body>
</html>
